/// <reference path="F:\Html5 Game\Game project\js\libs\kangax-fabric-48.306.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\DBAbstractionLayer.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\GameCanvas.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Node.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\NodeType.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Planet.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Region.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Scale.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\System.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Universe.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Utilities.js"/>
this.Region = function (regionEdgesList, name, systems) {

    // Declarations
    var obj = this;

    // Variables
    var regionEdgesList = regionEdgesList;
    var name = name;
    var image = new Image();
    var systemList = systems;

    // Constructor
    var _constructor = function () {
        image.src = "img/REGIONCONCEPT.png";
    }

    // Public functions
    obj.draw = function (context, scale) {
        try {
            if (scale == Scale.UNIVERSE) {
                context.fillStyle = '#00f';
                context.strokeStyle = '#f00';
                context.lineWidth = 1;
                context.beginPath();
                // Ye sorry, but we gotta skip first one and im lazy ^moveTo 
                context.moveTo(regionEdgesList[0].getX(), regionEdgesList[0].getY());
                for (edge in regionEdgesList) {
                    if (edge != 0) {
                        context.lineTo(regionEdgesList[edge].getX(), regionEdgesList[edge].getY());
                    }
                }
                context.stroke();
                context.closePath();
                context.font = "8px sans-serif";
                context.fillText(name, 20, 20);
            }
            else if (scale == Scale.REGION) {
                for (system in systemList) {
                    systemList[system].draw(context, scale);
                }
            }
            else {
                for (system in systemList) {
                    systemList[system].draw(context, scale);
                }
            }
        }
        catch (e) {
            var nom = e;
        }

    }
    //Private Functions
    _constructor();
};

